using System.Web.UI;
using System.Web.UI.WebControls;

namespace CommonLibrary.WebControls
{
	[ToolboxData("<{0}:SmartButton runat=\"server\" id=\"SmartButton1\" />")]
	public class SmartButton : Button
	{
		#region Private Fields

		private string  _loadingText;

		#endregion

		#region Public Properties

		/// <summary>
		/// The text to display on the button after disabling it
		/// </summary>
		public string LoadingText
		{
			get { return _loadingText ?? Text; }
			set
			{
				_loadingText = value;
				OnClientClick += string.Format("this.disabled = true; this.value= '{0}';", LoadingText);
			}
		}

		#endregion

		#region Event Handlers

		protected override void AddAttributesToRender(HtmlTextWriter writer)
		{
			base.AddAttributesToRender(writer);
		}

		#endregion
	}
}
